# protect the default target for this file from the targets in Makefile.global
# and Makefile.thirdparty
default: all

BLD_TOP=..
include $(BLD_TOP)/Makefile.global
include $(BLD_TOP)/Makefile.thirdparty

all: mkgpfdist mkdbgen mkgphdfs

.PHONY:
mkgpfdist:
	$(MAKE) -f Makefile.gpfdist INSTLOC=$(INSTLOC)

.PHONY:
mkdbgen:
	$(MAKE) -f Makefile.tpch INSTLOC=$(INSTLOC)

.PHONY:
mkgphdfs:
	PATH=$(INSTLOC)/bin:$(PATH) $(MAKE) -C gphdfs USE_PGXS=1 docdir=$(INSTLOC)/docs install \
		ANT=/opt/releng/apache-ant/bin/ant \
		JAVA_HOME=${JAVA_HOME}

# Use $JAVA_HOME if specified, otherwise look for java in the likely places.
# Note that Darwin's JVM layout is pretty weird.  JDK 1.6 apears to be the
# default for Snow Leopard, but JDK 1.5 is for Leopard.
# See http://developer.apple.com/qa/qa2001/qa1170.html
ifeq ($(wildcard "${JAVA_HOME}/bin/java"),)
  JDK="${JAVA_HOME}"
else
  ifeq ($(wildcard "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java"),)
    JDK="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
  else
    ifeq ($(wildcard "/usr/java/bin/java"),)
      JDK="/usr/java"
    else
      echo JAVA_HOME not found
    endif
  endif
endif
JAVA=${JAVA_HOME}/bin/java
JAVAC=${JAVA_HOME}/bin/javac
JAVAH=${JAVA_HOME}/bin/javah
JAR=${JAVA_HOME}/bin/jar
JAVADOC=${JAVA_HOME}/bin/javadoc

.PHONY:
mkpljava:
	PATH=$(INSTLOC)/bin:$(PATH) $(MAKE) -C pljava \
		JAVA_HOME=${JAVA_HOME} JAVA=${JAVA} JAVAC=${JAVAC} JAVAH=${JAVAH} JAR=${JAR} JAVADOC=${JAVADOC}  install

.PHONY:
mkplr:
	PATH=$(INSTLOC)/bin:$(PATH) $(MAKE) -C plr install USE_PGXS=1

.PHONY:
mkorafce:
	PATH=$(INSTLOC)/bin:$(PATH) $(MAKE) -C orafce install USE_PGXS=1

installcheck:
	PATH=$(INSTLOC)/bin:$(PATH) $(MAKE) -C orafce installcheck USE_PGXS=1
